include ../CouchControlBuild.mak
CPPFLAGS += $(INCL)
SOURCES=$(shell ls *.cpp)
OBJECTS=$(SOURCES:.cpp=.o)

# must find a way to address this
ifndef $(TARGET)
   TARGET = lib
endif

ifeq ($(OPTIMIZE), 1)
   CPPFLAGS += -O2
endif

.PHONY: depend clean

all: depend $(BLDTYPE)

shared: depend $(TARGET).so

static: depend $(TARGET).a

$(TARGET).so: $(OBJECTS)
	cp *.o ../bin/Lib

#	rm -f $@
#	$(CPP) $(LDLIBFLAGS) $(OBJECTS) -o $@

$(TARGET).a: $(OBJECTS) 
	cp *.o ../bin/Lib 
	
#	rm -f $@
#	$(AR) $@ $(OBJECTS)
#	$(RANLIB) $@

.cpp.o:
	$(CPP) $(CPPFLAGS) $< -o $@

clean:
	rm -f $(TARGET).* *.o lib* core* stXXXX* depends.mk
	touch depends.mk
	cd ../bin/Lib rm -f $(OBJECTS)

depend: $(SOURCES)
	$(CPP) $(CPPFLAGS) -M $^ > depends.mk

-include depends.mk
